package cn.funeralobjects.asms.converter;

import cn.funeralobjects.utils.aliyun.sms.enums.SendStatus;

import javax.persistence.AttributeConverter;

/**
 * Converter of SendStatus
 *
 * @author FuneralObjects
 * Create date: 2020/5/31 9:14 PM
 */
public class SendStatusConverter implements AttributeConverter<SendStatus, Short> {
    @Override
    public Short convertToDatabaseColumn(SendStatus attribute) {
        return attribute == null ? null : attribute.getNum();
    }

    @Override
    public SendStatus convertToEntityAttribute(Short dbData) {
        return dbData == null ? SendStatus.OTHER : SendStatus.of(dbData);
    }
}
